import requests
response=requests.get('https://www.baidu.com/')
print(response.cookies.get_dict())
#用session保存cookie
url='http://www.renren.com/880151247/profile'
session=requests.Session()
headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
        }
data={}
#session会保存cookie
login_response=session.post(url,data=data,headers=headers)

#登录成功之后 带着有效的cookies 访问 请求目标数据
data=session.get(url,headers=headers).content.decode()


